# Maintainer: Sébastien Luttringer
# Contributor: Valere Monseur <valere_monseur@hotmail.com>
# Contributor: Alessandro Sagratini <ale_sagra@hotmail.com>
# Contributor: Kevin Edmonds <edmondskevin@hotmail.com>

pkgname=conntrack-tools
pkgver=1.4.6
pkgrel=2
pkgdesc='Userspace tools to interact with the Netfilter connection tracking system'
arch=('x86_64')
url='https://www.netfilter.org/projects/conntrack-tools/'
license=('GPL2')
makedepends=('systemd' 'libtirpc')
depends=('glibc' 'libnetfilter_conntrack' 'libnetfilter_cttimeout'
         'libnetfilter_cthelper' 'libnetfilter_queue' 'libmnl' 'systemd-libs'
         'libnfnetlink')
backup=('etc/conntrackd.conf')
validpgpkeys=('C09DB2063F1D7034BA6152ADAB4655A126D292E4') # Netfilter Core Team
source=("https://www.netfilter.org/projects/$pkgname/files/$pkgname-$pkgver.tar.bz2"{,.sig}
        'conntrackd.service')
install=$pkgname.install
sha256sums=('590859cc848245dbfd9c6487761dd303b3a1771e007f4f42213063ca56205d5f'
            'SKIP'
            '8ffdd2130be8f5a80c80b1784f18f857d4af0acb9a392d67c1f8c7212436d85e')

prepare() {
  sed -i -e 's,/etc/conntrackd/,/etc/,' -e 's,/var/lock/,/run/lock/,' \
    $pkgname-$pkgver/include/conntrackd.h
}


build() {
  cd $pkgname-$pkgver
  ./configure  \
    LIBNETFILTER_CTHELPER_CFLAGS='-I /usr/include/tirpc/' \
    --prefix=/usr \
    --sysconfdir=/etc \
    --sbindir=/usr/bin \
    --enable-systemd
  make
}

package() {
  # install binaries
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  # systemd
  cd "$pkgdir"
  install -D -m 644 "$srcdir/conntrackd.service" usr/lib/systemd/system/conntrackd.service
  # install empty configuration files
  install -D -m 644 /dev/null etc/conntrackd.conf
}

# vim:set ts=2 sw=2 et:
